#include "statusbar/StatusBar.h"
#include <QFile>
#include <QLabel>
#include <QFont>
#include <qnamespace.h>
#include <qsize.h>

StatusBar::StatusBar(QWidget *parent) : QStatusBar(parent) {
    setFixedHeight(18);

    initUI();

    QLabel *label = new QLabel(this);
    label->setText(" 输出： ");
    label->setFixedHeight(18);
    label->setAlignment(Qt::AlignVCenter);
    leftLayout->addWidget(label);

    loadStyleSheet();


}

StatusBar::~StatusBar(){};

void StatusBar::initUI() {
    mainLayout = new QHBoxLayout(this);
    mainLayout->setContentsMargins(0, 0, 0, 0);

    leftLayout = new QHBoxLayout;
    leftLayout->setContentsMargins(0, 0, 0, 0);
    leftLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));

    rightLayout = new QHBoxLayout;
    rightLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum));
    rightLayout->setContentsMargins(0, 0, 0, 0);

    mainLayout->addLayout(leftLayout);
    mainLayout->addLayout(rightLayout);

    setLayout(mainLayout);
}

void StatusBar::loadStyleSheet() {
    QFile file(QString(":/resources/style/statusbar.qss"));
    file.open(QFile::ReadOnly);
    if (file.isOpen()) {
        QString styleSheet = this->styleSheet();
        styleSheet += file.readAll();
        this->setStyleSheet(styleSheet);
    }

}